<?php


/**
 * Base class that represents a query for the 'module' table.
 *
 * 
 *
 * @method     ModuleQuery orderByModuleid($order = Criteria::ASC) Order by the moduleID column
 * @method     ModuleQuery orderByMenuid($order = Criteria::ASC) Order by the menuID column
 * @method     ModuleQuery orderByContentid($order = Criteria::ASC) Order by the contentID column
 * @method     ModuleQuery orderByNaam($order = Criteria::ASC) Order by the naam column
 * @method     ModuleQuery orderByModule($order = Criteria::ASC) Order by the module column
 * @method     ModuleQuery orderByVolgorde($order = Criteria::ASC) Order by the volgorde column
 * @method     ModuleQuery orderByRank($order = Criteria::ASC) Order by the rank column
 *
 * @method     ModuleQuery groupByModuleid() Group by the moduleID column
 * @method     ModuleQuery groupByMenuid() Group by the menuID column
 * @method     ModuleQuery groupByContentid() Group by the contentID column
 * @method     ModuleQuery groupByNaam() Group by the naam column
 * @method     ModuleQuery groupByModule() Group by the module column
 * @method     ModuleQuery groupByVolgorde() Group by the volgorde column
 * @method     ModuleQuery groupByRank() Group by the rank column
 *
 * @method     ModuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method     ModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method     ModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method     ModuleQuery leftJoinMenu($relationAlias = null) Adds a LEFT JOIN clause to the query using the Menu relation
 * @method     ModuleQuery rightJoinMenu($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Menu relation
 * @method     ModuleQuery innerJoinMenu($relationAlias = null) Adds a INNER JOIN clause to the query using the Menu relation
 *
 * @method     ModuleQuery leftJoinContent($relationAlias = null) Adds a LEFT JOIN clause to the query using the Content relation
 * @method     ModuleQuery rightJoinContent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Content relation
 * @method     ModuleQuery innerJoinContent($relationAlias = null) Adds a INNER JOIN clause to the query using the Content relation
 *
 * @method     Module findOne(PropelPDO $con = null) Return the first Module matching the query
 * @method     Module findOneOrCreate(PropelPDO $con = null) Return the first Module matching the query, or a new Module object populated from the query conditions when no match is found
 *
 * @method     Module findOneByModuleid(int $moduleID) Return the first Module filtered by the moduleID column
 * @method     Module findOneByMenuid(int $menuID) Return the first Module filtered by the menuID column
 * @method     Module findOneByContentid(int $contentID) Return the first Module filtered by the contentID column
 * @method     Module findOneByNaam(string $naam) Return the first Module filtered by the naam column
 * @method     Module findOneByModule(string $module) Return the first Module filtered by the module column
 * @method     Module findOneByVolgorde(int $volgorde) Return the first Module filtered by the volgorde column
 * @method     Module findOneByRank(int $rank) Return the first Module filtered by the rank column
 *
 * @method     array findByModuleid(int $moduleID) Return Module objects filtered by the moduleID column
 * @method     array findByMenuid(int $menuID) Return Module objects filtered by the menuID column
 * @method     array findByContentid(int $contentID) Return Module objects filtered by the contentID column
 * @method     array findByNaam(string $naam) Return Module objects filtered by the naam column
 * @method     array findByModule(string $module) Return Module objects filtered by the module column
 * @method     array findByVolgorde(int $volgorde) Return Module objects filtered by the volgorde column
 * @method     array findByRank(int $rank) Return Module objects filtered by the rank column
 *
 * @package    propel.generator.database.om
 */
abstract class BaseModuleQuery extends ModelCriteria
{

	/**
	 * Initializes internal state of BaseModuleQuery object.
	 *
	 * @param     string $dbName The dabase name
	 * @param     string $modelName The phpName of a model, e.g. 'Book'
	 * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
	 */
	public function __construct($dbName = 'database', $modelName = 'Module', $modelAlias = null)
	{
		parent::__construct($dbName, $modelName, $modelAlias);
	}

	/**
	 * Returns a new ModuleQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    ModuleQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof ModuleQuery) {
			return $criteria;
		}
		$query = new ModuleQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}

	/**
	 * Find object by primary key
	 * Use instance pooling to avoid a database query if the object exists
	 * <code>
	 * $obj  = $c->findPk(12, $con);
	 * </code>
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    Module|array|mixed the result, formatted by the current formatter
	 */
	public function findPk($key, $con = null)
	{
		if ((null !== ($obj = ModulePeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
			// the object is alredy in the instance pool
			return $obj;
		} else {
			// the object has not been requested yet, or the formatter is not an object formatter
			$criteria = $this->isKeepQuery() ? clone $this : $this;
			$stmt = $criteria
				->filterByPrimaryKey($key)
				->getSelectStatement($con);
			return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
		}
	}

	/**
	 * Find objects by primary key
	 * <code>
	 * $objs = $c->findPks(array(12, 56, 832), $con);
	 * </code>
	 * @param     array $keys Primary keys to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
	 */
	public function findPks($keys, $con = null)
	{	
		$criteria = $this->isKeepQuery() ? clone $this : $this;
		return $this
			->filterByPrimaryKeys($keys)
			->find($con);
	}

	/**
	 * Filter the query by primary key
	 *
	 * @param     mixed $key Primary key to use for the query
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKey($key)
	{
		return $this->addUsingAlias(ModulePeer::MODULEID, $key, Criteria::EQUAL);
	}

	/**
	 * Filter the query by a list of primary keys
	 *
	 * @param     array $keys The list of primary key to use for the query
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKeys($keys)
	{
		return $this->addUsingAlias(ModulePeer::MODULEID, $keys, Criteria::IN);
	}

	/**
	 * Filter the query on the moduleID column
	 * 
	 * @param     int|array $moduleid The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByModuleid($moduleid = null, $comparison = null)
	{
		if (is_array($moduleid) && null === $comparison) {
			$comparison = Criteria::IN;
		}
		return $this->addUsingAlias(ModulePeer::MODULEID, $moduleid, $comparison);
	}

	/**
	 * Filter the query on the menuID column
	 * 
	 * @param     int|array $menuid The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByMenuid($menuid = null, $comparison = null)
	{
		if (is_array($menuid)) {
			$useMinMax = false;
			if (isset($menuid['min'])) {
				$this->addUsingAlias(ModulePeer::MENUID, $menuid['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($menuid['max'])) {
				$this->addUsingAlias(ModulePeer::MENUID, $menuid['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ModulePeer::MENUID, $menuid, $comparison);
	}

	/**
	 * Filter the query on the contentID column
	 * 
	 * @param     int|array $contentid The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByContentid($contentid = null, $comparison = null)
	{
		if (is_array($contentid)) {
			$useMinMax = false;
			if (isset($contentid['min'])) {
				$this->addUsingAlias(ModulePeer::CONTENTID, $contentid['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($contentid['max'])) {
				$this->addUsingAlias(ModulePeer::CONTENTID, $contentid['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ModulePeer::CONTENTID, $contentid, $comparison);
	}

	/**
	 * Filter the query on the naam column
	 * 
	 * @param     string $naam The value to use as filter.
	 *            Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByNaam($naam = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($naam)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $naam)) {
				$naam = str_replace('*', '%', $naam);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(ModulePeer::NAAM, $naam, $comparison);
	}

	/**
	 * Filter the query on the module column
	 * 
	 * @param     string $module The value to use as filter.
	 *            Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByModule($module = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($module)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $module)) {
				$module = str_replace('*', '%', $module);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(ModulePeer::MODULE, $module, $comparison);
	}

	/**
	 * Filter the query on the volgorde column
	 * 
	 * @param     int|array $volgorde The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByVolgorde($volgorde = null, $comparison = null)
	{
		if (is_array($volgorde)) {
			$useMinMax = false;
			if (isset($volgorde['min'])) {
				$this->addUsingAlias(ModulePeer::VOLGORDE, $volgorde['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($volgorde['max'])) {
				$this->addUsingAlias(ModulePeer::VOLGORDE, $volgorde['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ModulePeer::VOLGORDE, $volgorde, $comparison);
	}

	/**
	 * Filter the query on the rank column
	 * 
	 * @param     int|array $rank The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByRank($rank = null, $comparison = null)
	{
		if (is_array($rank)) {
			$useMinMax = false;
			if (isset($rank['min'])) {
				$this->addUsingAlias(ModulePeer::RANK, $rank['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($rank['max'])) {
				$this->addUsingAlias(ModulePeer::RANK, $rank['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ModulePeer::RANK, $rank, $comparison);
	}

	/**
	 * Filter the query by a related Menu object
	 *
	 * @param     Menu $menu  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByMenu($menu, $comparison = null)
	{
		return $this
			->addUsingAlias(ModulePeer::MENUID, $menu->getMenuid(), $comparison);
	}

	/**
	 * Adds a JOIN clause to the query using the Menu relation
	 * 
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function joinMenu($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Menu');
		
		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}
		
		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Menu');
		}
		
		return $this;
	}

	/**
	 * Use the Menu relation Menu object
	 *
	 * @see       useQuery()
	 * 
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    MenuQuery A secondary query class using the current class as primary query
	 */
	public function useMenuQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		return $this
			->joinMenu($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Menu', 'MenuQuery');
	}

	/**
	 * Filter the query by a related Content object
	 *
	 * @param     Content $content  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function filterByContent($content, $comparison = null)
	{
		return $this
			->addUsingAlias(ModulePeer::CONTENTID, $content->getContentid(), $comparison);
	}

	/**
	 * Adds a JOIN clause to the query using the Content relation
	 * 
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Content');
		
		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}
		
		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Content');
		}
		
		return $this;
	}

	/**
	 * Use the Content relation Content object
	 *
	 * @see       useQuery()
	 * 
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    ContentQuery A secondary query class using the current class as primary query
	 */
	public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		return $this
			->joinContent($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Content', 'ContentQuery');
	}

	/**
	 * Exclude object from result
	 *
	 * @param     Module $module Object to remove from the list of results
	 *
	 * @return    ModuleQuery The current query, for fluid interface
	 */
	public function prune($module = null)
	{
		if ($module) {
			$this->addUsingAlias(ModulePeer::MODULEID, $module->getModuleid(), Criteria::NOT_EQUAL);
	  }
	  
		return $this;
	}

} // BaseModuleQuery
